package com.inspur.cloud.service.dataspace;

import com.inspur.cloud.dao.dataspace.HbaseResourceDao;
import com.inspur.cloud.entity.dataspace.HbaseResourceEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class HbaseResourceService {
    @Autowired
    private HbaseResourceDao hbaseResourceDao;

    public HbaseResourceEntity findHbaseResourceEntityById(Integer resourceId){
        return hbaseResourceDao.findHbaseResourceEntityById(resourceId);
    }
    public HbaseResourceEntity findBySpaceName(String spaceName){
        return hbaseResourceDao.findBySpaceName(spaceName);
    }
    public HbaseResourceEntity findFirstByOwner(Integer owner){
        return hbaseResourceDao.findFirstByOwner(owner);
    }
    public HbaseResourceEntity findByTableNameAndParentId(String tableName, Integer parentId){
        return hbaseResourceDao.findByTableNameAndParentId(tableName,parentId);
    }
    public HbaseResourceEntity findByColumnNameAndParentId(String columnName, Integer parentId){
        return hbaseResourceDao.findByColumnNameAndParentId(columnName,parentId);
    }
    public HbaseResourceEntity findByColumnFamilyNameAndParentId(String columnName, Integer parentId){
        return hbaseResourceDao.findByColumnFamilyNameAndParentId(columnName,parentId);
    }
    public Integer findSonNum(Integer id){
        return hbaseResourceDao.findSonNum(id);
    }
    public List<HbaseResourceEntity> findByParentId(Integer parentId){
        return hbaseResourceDao.findByParentId(parentId);
    }
    public  List<Integer> findIdByParentId(Integer parentId){
        return hbaseResourceDao.findIdByParentId(parentId);
    }
    @Transactional(transactionManager = "transactionManagerDataspace")
    public  Integer deleteByParentId(Integer parentId){
        return hbaseResourceDao.deleteByParentId(parentId);
    }
    public List<HbaseResourceEntity> findByLevelAndStatus(Integer level, Integer status){
        return hbaseResourceDao.findByLevelAndStatus(level,status);
    }

    public List<HbaseResourceEntity> findAll() {
        return hbaseResourceDao.findAll();
    }
    public List<HbaseResourceEntity> findByLevelAndStatusAndOwner(Integer level, Integer status, Integer owner){
        return hbaseResourceDao.findByLevelAndStatusAndOwner(level,status,owner);
    }
    @Transactional(transactionManager = "transactionManagerDataspace")
    public Integer hideByParentId(Integer parentId){
        return hbaseResourceDao.hideByParentId(parentId);
    }
    @Transactional(transactionManager = "transactionManagerDataspace")
    public void save(HbaseResourceEntity hbaseResourceEntity){
        hbaseResourceDao.save(hbaseResourceEntity);
    }
    @Transactional(transactionManager = "transactionManagerDataspace")
    public void deleteById(Integer resourceId){
        hbaseResourceDao.deleteById(resourceId);
    }

}
